// 通知公告路由
import { Router } from 'express';
import { authMiddleware } from '@/middlewares/auth.middleware';
import { permissionMiddleware } from '@/middlewares/permission.middleware';
import noticeController from '@/controllers/system/notice.controller';
import { createController } from '@/utils/router/route.controller';
import { validateNoticeCreate, validateNoticeUpdate, validateNoticeRemove, validateNoticeDetail } from '@/validators/system/notice.validator';

const router = createController(Router());

/**
 * 通知公告路由
 * 路径前缀：/system/notice
 */

// 所有路由均需认证
router.use(authMiddleware);


// ================== 公告相关 ==================
// 公告分页列表
router.get('/list', permissionMiddleware('system:notice:list'), noticeController.list);

// 公告详情
router.get('/:noticeId', permissionMiddleware('system:notice:query'), validateNoticeDetail, noticeController.detail);

// ================== 新增、修改、删除 ==================
// 新增公告（自动记录操作日志）
router.POST('', permissionMiddleware('system:notice:add'), validateNoticeCreate, noticeController.add);

// 修改公告（自动记录操作日志）
router.PUT('', permissionMiddleware('system:notice:edit'), validateNoticeUpdate, noticeController.update);

// 删除公告（自动记录操作日志）
router.DELETE('/:noticeIds', permissionMiddleware('system:notice:remove'), validateNoticeRemove, noticeController.remove);

export default router; 